<meta charset="UTF-8">
<#include "common/common.html"/>
<table
	     class="easyui-datagrid"   
	     id="datagrid"  
         title="审核资金管理"  
         url="${base}/fundBack/queryList?statusIds=202,203,204"
         toolbar="#searchtool,#toolbar" 
         pagination="true"
         rownumbers="true" 
         fitColumns="true"
         singleSelect="true"
         data-options="fit:false,border:false,pageSize:20,pageList:[5,10,15,20]" >  
       <thead>  
        <tr>
            <th field="id" width="8%" checkbox="true"></th>         
            <th field="fundNo" width="4%">资金编号</th>  
            <th field="titlesVal" width="10%">资金名称</th>
            <th field="industryName" width="8%">投资行业</th>
            <th field="destinationName" width="8%">投资地区</th>  
            <th field="userPhone" width="5%">手机号</th> 
            <th field="userName" width="4%">发布人</th>
            <th field="total" width="5%">投资金额（万）</th>
            <th field="investMode" formatter="investModeType" width="5%">项目类型</th>
            <th field="state" formatter="formatFundState" width="3%">资金状态</th>     
            <th field="auth" formatter="formatauth" width="3%">认证状态</th>  
            <th field="pushTime" width="5%">发布时间</th>  
            <th field="descrition" width="5%">资金简介</th>  
            <th field="requirement" width="5%">备注</th>  
            <th field="operatorNames" width="5%">操作员</th>   
            <th width="18%" data-options="field:'_operate',align:'center',formatter:formatOper">操作</th>  
            <th data-options="field:'userId',width:85,align:'center',hidden:true" ></th>
            <th data-options="field:'industryId',width:85,align:'center',hidden:true" ></th>
            <th data-options="field:'operatorId',width:85,align:'center',hidden:true" ></th> 
            <th data-options="field:'destination',width:85,align:'center',hidden:true" ></th>   
            <th data-options="field:'intentionName',width:85,align:'center',hidden:true" ></th> 
            <th data-options="field:'intention',width:85,align:'center',hidden:true" ></th> 
        </tr>  
    </thead>  
</table>  



<div id="searchtool" style="padding:5px">  
<form id="searchForm" method="post">
  <span>关键字搜索:</span><input type="text" id="keyword" name="keyword" placeholder="资金名称/发布人/资金编号" value="" size=20 /> 
  <span>投资行业:</span> <input  class="easyui-combobox" name="industryId"   
    data-options="valueField:'id',textField:'industryName',panelHeight:'auto',editable:false,url:'${base}/industry/querySquAll',loadFilter:function(data){
    			    data.unshift({id:'',industryName:'全部'});
    			    return data;
    		      }," />  
  <span>投资地区:</span><input  class="easyui-combobox" name="destination"   
              data-options="valueField:'postcode',textField:'cityName',editable:false,url:'${base}/cityinfo/findAllProvince', loadFilter:function(data){
    			    data.unshift({postcode:'0',cityName:'全国'});
    			    return data;
    		      }" />  
  <span>资金状态:</span><select  class="easyui-combobox" name="state" editable="false">   
				<option value="">全部</option> 
				<option value="202">已提交</option> 
				<option value="203">已发布</option> 
				<option value="204">已撤回</option>
               </select>  
  <span>开始时间:</span><input name="startTime" class="easyui-datebox" data-options="formatter:myformatter,parser:myparser" style="width:200px" >  
  <span>结束时间:</span><input name="endTime" class="easyui-datebox"  data-options="formatter:myformatter,parser:myparser" style="width:200px" >  
  <span>项目类型:</span>
               <input  class="easyui-combobox" name="investMode"   editable="false"
    data-options="valueField:'itemCode',textField:'itemName',loadFilter:investModeFilter,url:'${base}/dictionary/initByParentCode?parentCode=300',loadFilter:function(data){
    			    data.unshift({itemCode:'',itemName:'全部'});
    			    return data;
    		      },"  />  
    
  <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="javascript:doSearch('searchForm');">搜索</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="javascript:$('#searchForm').form('clear');">清空</a>  
  </form>
</div>
<div id="toolbar">
        
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="javascript:updateStatus('发布',203);">发布</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="javascript:updateStatus('撤回',204);">撤回</a>

</div> 


<div id="preView" class="easyui-window"  style="padding:10px 20px" closed="true" modal="true">
</div>
<div id="intentionDiv" class="easyui-window"  style="padding:10px 20px" closed="true" modal="true">
</div>
<script type="text/javascript">
function investModeFilter(data){
	 data.unshift({itemCode:'0',itemName:''});
	   return data;
}
function investModeType(val){
	if (val == 301){
		return '股权';
	} else if(val == 302){
		return '债权';
	}else if(val == 303){
		return '资产交易';
	}else if(val == 304){
		return '政府招商';
	}else {
		return '未知';
	}
}

function formatauth(val){
	if (val == 501){
		return '已认证';
	} else if(val == 502){
		return '实地认证';
	}else {
		return '未认证';
	}
}

//状态:1-未激活,2-已锁定,3-已注销,11-正常但未认证，12-正常已认证
function formatStatus(val,row,index){
   if(val==1){
 	  return "未激活";
   }else if(val==2){
 	  return "已锁定"; 
   }else if(val==3){
		return '已删除';
	}else if(val==11){
		return '未核实';
	}else if(val==12){
		return '已核实';
	}else{
		return '未知';
	}

}

function updateStatus(title,status){
	var rows = $('#datagrid').datagrid('getSelections');
   if (rows.length>0){
   	var ids = [];
   	for(var i=0; i<rows.length; i++){
   		ids.push(rows[i].id);
   	}
   	url = $("#base").val()+"/fundBack/updateStatus?ids="+ids.join(",")+"&status="+status;
       $.messager.confirm(title,'确定要'+title+'吗?',function(r){
           if (r){
               $.post(url,function(result){
               	var result = eval('('+result+')');
               	if (result.errorMsg){
                	   $.messager.alert('错误',"修改信息状态失败,请稍后再试",'error');
                	  $('#datagrid').datagrid('reload'); 
                   } else if(result.infoMsg){
                	   $.messager.alert('提示',"修改信息状态成功",'info');
                	  $('#datagrid').datagrid('reload'); 
                   }else{
                      $('#datagrid').datagrid('reload');   
                   }
               });
           }
       });
   }else{
   	 $.messager.alert('提示','请选择一条信息进行操作','info');
   }
}
var $wins;
function showUser(id){
   var windowWidth =$(window.parent).width();
   var windowHeight=$(window.parent).height();
   var width= windowWidth-100;
   var height=windowHeight-200;
   var top=(windowHeight-height)/2;
   var left=(windowWidth-width)/2;
    $wins = $('#intentionDiv').window({
    	href: 'userStatistic/showUser?id='+id+'&noCache=random',
        title: '显示关注人',
        width: width,
        height: height,
        top: top,
        left: left,
        shadow: true,
        modal: true,
        iconCls: 'icon-add',
        closed: true,
        minimizable: false,
        maximizable: false,
        collapsible: false
    });
    $('#datagrid').datagrid('clearSelections');
    $wins.window('open');
}


function formatOper(val,row,index){
	var managePhotoUrl ="fundBack/managePhoto?id="+row.id;
	var managePhoto = "<a href='javascript:open(\""+managePhotoUrl+"\");'>|图集管理</a>";
	var showUser = "<a href='javascript:showUser(\""+row.id+"\");'>显示关注人</a>";
	var managePhotoUrl ="fundBack/managePhoto?id="+row.id;
	//发布状态下，图片管理不显示
	if(row.state == 203){
		managePhoto="";
	}
    return '<a href="javascript:showAppFund('+index+')">APP预览</a>'+"|"+showUser+managePhoto;  
    }
    
var $winst;
function showAppFund(index){
	$('#datagrid').datagrid('selectRow',index);// 关键在这里  
	
    var rows = $('#datagrid').datagrid('getSelections');
    if (rows.length>0){
    var href= '${mobileDomain}/fund/detail?id='+rows[0].id+'&noCache=random';
    var windowWidth =$(window.parent).width();
    var windowHeight=$(window.parent).height();
    var width=380;
    var height=windowHeight-200;
    var top=(windowHeight-height)/2;
    var left=(windowWidth-width)/2;
    var $winst = $('#preView').window({
   	   content : '<iframe scrolling="yes" frameborder="0"  src="'  
              + href  
              + '" style="width:100%;height:98%;"></iframe>',  
        title: 'APP预览',
        width: width,
        height: height,
        top: top,
        left: left,
        shadow: true,
        modal: true,
        closed: true,
        minimizable: false,
        maximizable: false,
        collapsible: false
    });

    $winst.window('open');
    }
}
</script>

